
#ifndef Velyn_VertexTriangleMesh_h
#define Velyn_VertexTriangleMesh_h

#include <vector>

#include "Vertex.h"

using namespace std;

namespace Velyn {

    // VertexTriangleMeshTypes
    typedef vector<Vertex> VertexList;
    typedef vector<int> TriangleList;
    
    class VertexTriangleMesh {
    
    private:
    
        // vertexlist
        VertexList vertexList;
        
        // trianglelist
        TriangleList triangleList;
        
        // dirty bit
        bool dirty;

    public:
    
        VertexTriangleMesh() : dirty(true) {}
        
        VertexTriangleMesh(const VertexTriangleMesh& mesh) : dirty(true) {
            vertexList = mesh.vertexList;
            triangleList = mesh.triangleList;
        }
        
        ~VertexTriangleMesh() {}
        
        bool isDirty() {
            return dirty;
        }
        
        void isClean() {
            dirty = false;
        }
        
        void clear() {
            vertexList.clear();
            triangleList.clear();
            dirty = true;
        }

        void addVertex(const float x, const float y, const float z, const float u, const float v) {
            vertexList.push_back(Vertex(x, y, z, u, v));
            dirty = true;
        }
        
        void addTriangle(const int vertex0, const int vertex1, const int vertex2) {
            triangleList.push_back(vertex0);
            triangleList.push_back(vertex1);
            triangleList.push_back(vertex2);
            dirty = true;
        }
        
        VertexList::iterator vertexBegin() {
            return (VertexList::iterator) VertexList.begin();
        }
        
        VertexList::iterator vertexEnd() {
            return (VertexList::iterator) VertexList.end();
        }
}

#endif
